<?php

namespace app\common\enums;

class QuestionTypeEnum extends BaseEnum
{
    // 定义常量
    public const E1 = '1';
    public const E2 = '2';

    // 定义描述
    public array $description = [
        self::E1 => '单选',
        self::E2 => '多选'
    ];

    /**
     * 根据类型字符串获取题目类型
     *
     * @param string $type 类型字符串
     * @return string|null 题目类型常量或null
     */
    public static function getType($type)
    {
        switch ($type) {
            case '单选':
            case '单选题':
                return self::E1;
            case '多选':
            case '多选题':
                return self::E2;
        }
        return null;
    }
}
